<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>128-动画-匀速动画基本使用.html</title>
	<style>
		*{
			margin: 0;
			padding: 0;
		}
		#box{
			position: absolute;
			top: 50px;
			left: 0;
			width: 100px;
			height: 100px;
			background:skyblue;
			transition: all 5s linear;
		}
		.line{
			width: 1px;
			height: 400px;
			background: #000;
			position: absolute;
			top: 0;
			left: 400px;
		}
	</style>
</head>
<body>
	<button id="btn">开始动画</button>
	<div id="box"></div>
	<div class="line"></div>

</body>
<script>
	// var w =0,h=0;
	// if(document.compatMode =='css1compat'){
	// 	w = document.documentElement.clientWidth;
	// 	h = document.documentElement.clientHeight;
	// }else{
	// 	w = document.body.clientWidth;
	// 	h = document.body.clientHeight;
	// }
	
	var oBtn = document.getElementById('btn');
	var oBox = document.getElementById('box');
	var timer = null;

	oBtn.onclick = function(){
		// oBox.style.left = "400px";
		timer = setInterval(function(){
			if(oBox.offsetLeft == 400){
				clearInterval(timer);
			}
			oBox.style.left = oBox.offsetLeft + 5000 +"px";
		},30)
	}
</script>
</html>